#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    client_requests_suds.py
    ~~~~~~~~~~~~~~~~~~~~~~~

    模拟客户端请求——suds版本

    :author: nut
    :copyright: (c) 2020, Comcat
    :date created: 2020-12-01
    :python version: 3.7
"""
from suds.client import Client

host = '127.0.0.1'
port = 8902

client = Client('http://%s:%s/?wsdl' % (host, port))
# print(client) # 打印wsdl内容
# print('=' * 20)

persons = client.service.say_hello('zhangsan', 2)
print(persons)

print('-' * 20)
person = {}
person['name'] = 'zhangsan'
person['age'] = 23

persons = client.factory.create('PersonArray')
persons.Person.append(person)
persons.Person.append(person)
person = client.service.say_hello_1(persons)
print(person)

print('=' * 20)
persons = client.factory.create('stringArray')
persons.string.append('lisi')
persons.string.append('zhangsan')
person = client.service.say_hello_2(persons)
print(person)

print('=' * 20)
pers = {"name": u"张三", "age": 23}
result = client.service.say_hello_3(pers)
print(result)